import DetailPageContainer from "../components/DetailPageContainer";
import Steps from "./Steps";
import OrderInformation from "./OrderInformation";
import RefundDetails from "./RefundDetails";
import { useRequest } from "ahooks";
import { getOrderDetail } from "@/api/modules/transactionManagement";
import useUrl from "@/hooks/useUrl";
import Loading from "@/components/Loading";
import JudgeStatus from "../JudgeStatus";

export default () => {
	const { query } = useUrl();

	const order_id = query.get("order_id");

	const { data, loading, runAsync } = useRequest(getOrderDetail, { defaultParams: [{ order_id }] });

	const detailData = data?.data ?? {};

	//是否是退款中
	const isRefund = JudgeStatus.isInRefunded(detailData);

	console.log("=========data:", detailData);

	// is_all_send :1  全部发货  0 部分发货

	return (
		<Loading isHeight100 loading={loading}>
			<DetailPageContainer>
				<Steps
					data={detailData}
					getDetail={async () => {
						runAsync({ order_id });
					}}
				/>
				{isRefund && <RefundDetails data={detailData} />}
				<OrderInformation data={detailData} />
			</DetailPageContainer>
		</Loading>
	);
};
